home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CWindows.h
-
- Contains: Layer built on top of the Window Manager
-
- Written by: Arno Gourdol
-
- Copyright: © 1994-1995 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #pragma once
-
- #ifndef __CWINDOWS__
- #define __CWINDOWS__
-
- #include <Windows.h>
- #include "TDrawContext.h"
-
- enum
- {
- keyHome = 0x01,
- keyEnter = 0x03,
- keyEnd = 0x04,
- keyHelp = 0x05,
- keyArrowLeft = 0x1C,
- keyArrowRight = 0x1D,
- keyArrowUp = 0x1E,
- keyArrowDown = 0x1F,
- keyBackspace = 0x08,
- keyTab = 0x09,
- keyLineFeed = 0x0A,
- keyPageUp = 0x0B,
- keyPageDown = 0x0C,
- keyReturn = 0x0D,
- keySpace = 0x20,
- keyF1 = 0x7A00,
- keyF2 = 0x7800,
- keyF3 = 0x6300,
- keyF4 = 0x7600,
- keyUndo = keyF1,
- keyCut = keyF2,
- keyCopy = keyF3,
- keyPaste = keyF4,
- keyF5 = 0x6000,
- keyF6 = 0x6100,
- keyF7 = 0x6200,
- keyF8 = 0x6400,
- keyF9 = 0x6500,
- keyF10 = 0x6D00,
- keyF11 = 0x6700,
- keyF12 = 0x6F00,
- keyF13 = 0x6900,
- keyF14 = 0x6B00,
- keyF15 = 0x7100,
- keyFwdDel = 0x7500,
- keyClear = 0x1B,
- keyEscape = 0x11B
- };
-
- class CWindow
- {
- enum
- {
- kModelessWindow = 1,
- kApplicationModalWindow = 2,
- kSystemModalWindow = 4
- };
- public:
- // constructor
- CWindow(UInt16 windowType = kModelessWindow);
-
- // destructor
- virtual ~CWindow();
-
- // closing
- virtual void Close(void);
- virtual Boolean CloseRequested(void);
-
- // Menus
- virtual void MenusWillShow(void);
-
- // events
- virtual Boolean FilterEvent(const EventRecord &event);
- virtual void WindowActivated(Boolean active);
- virtual void MouseDown(const EventRecord& event);
- virtual Boolean FilterKey(const EventRecord& event, UInt16 key);
- virtual void Pulse(void);
- void ResizeBy(GraphicalUnit dx, GraphicalUnit dy);
- void ResizeTo(GraphicalUnit width, GraphicalUnit height);
- void Zoom(Boolean zoomOut = false);
-
- // others
- virtual WindowRef MakeWindow(void);
- inline void CreateWindow(void);
-
- void MoveTo(const CPoint& location);
- virtual void FrameResized(GraphicalUnit newWidth, GraphicalUnit newHeight);
- virtual void FrameMoved(const CPoint& newLocation);
-
- // screen management
- virtual void Show(void);
- virtual void Hide(void);
- GDHandle GetMaxIntersectedDevice(class CRect& screenRect);
- virtual void ForceOnScreen(void);
- void DoUpdate(RgnHandle area);
- virtual void Draw(TDrawContext& drawContext) = 0;
- void DrawGrowIcon(TDrawContext& drawContext) const;
- void SetSizeLimits( GraphicalUnit minH, GraphicalUnit maxH,
- GraphicalUnit minV, GraphicalUnit maxV);
-
- // selectors
- inline WindowRef GetWindowRef(void) const;
- inline UInt16 GetWindowType(void) const;
- inline GrafPtr GetGrafPtr(void) const;
- inline CRect Bounds(void) const;
-
- // Windows iteration
- static CWindow* GetCWindow(WindowRef window);
- inline static CWindow* GetFirstWindow(void) { return gWindowList; };
- inline CWindow* GetNextWindow(void) const;
- inline void SetNextWindow(CWindow* window);
-
- protected:
- WindowRef fWindow;
- UInt16 fWindowType;
-
- // User Interface
- // ??? Add maximum and minimum size to the window
- CRect fExtent; // Maximum size of the window
-
- private:
- // linked list of windows used to turn dialog pointers into CDialogs
- static CWindow *gWindowList;
- CWindow *fNextWindow;
-
- static pascal void DrawDispatch(short depth, short deviceFlags, GDHandle targetDevice, CWindow* window);
-
- };
-
-
- inline void CWindow::CreateWindow(void)
- {
- fWindow = MakeWindow();
- }
-
- inline UInt16 CWindow::GetWindowType(void) const
- {
- return fWindowType;
- }
-
-
- inline WindowRef CWindow::GetWindowRef(void) const
- {
- return fWindow;
- }
-
- inline GrafPtr CWindow::GetGrafPtr(void) const
- {
- return (GrafPtr)::GetWindowPort(GetWindowRef());
- }
-
- CRect CWindow::Bounds(void) const
- {
- return TDrawContext(GetGrafPtr()).Bounds();
- }
-
- CWindow *CWindow::GetNextWindow(void) const
- {
- return fNextWindow;
- }
-
-
- void CWindow::SetNextWindow(CWindow *window)
- {
- fNextWindow = window;
- }
-
- #endif
-